
int err_status = 0;
int string2int(char* str){ //convert an ascii string to integer
	if(str == nullptr){
		err_status = -1;
		return 0;
	}
	int sign = 1;
	int n = 0;
	if(*str == '-') {
		sign = -1;
		++str;
	}
	else if(*str == '+')
		++str;
	while(*str!='\0') {
		if((*str-'0')<0 || (*str-'9')>0) {
			err_status = -2;
			return 0;
		}
		n = n*10 + (*str-'0');
		++str;
	}
	n = n*sign;
	err_status = 0;
	return n;
}